﻿namespace NB.MGJ.Common
{
    /// =======================================================================
    /// 类名：CommonCode
    /// <summary>
    /// 全局常量及枚举定义
    /// </summary>
    /// <remarks>
    /// 全局常量及枚举定义
    /// </remarks>
    /// =======================================================================
    /// 更新履历
    /// 序号          修改日期          责任人           更新内容
    /// 001           2011/11/05        陈峰           新建
    /// =======================================================================
    public partial class CommonCode
    {
        /// <summary>
        /// 全局常量
        /// </summary>
        public struct GlobalConstant
        {
            /// <summary>
            /// 登录用户Session键
            /// </summary>
            public const string UserSessionKey = "LoginUser";

            /// <summary>
            /// Oauth登录用户SessionKey
            /// </summary>
            public const string OauthUserSessionKey = "SessionKey_OauthUser";

            /// <summary>
            /// Oauth授权应用信息
            /// </summary>
            public const string OauthClientInfo = "SessionKey_OauthClient";

            /// <summary>
            /// 请求Token Session键
            /// </summary>
            public const string Request_Token_Session = "Request_Token";

            /// <summary>
            /// 请求Token密钥 Session键
            /// </summary>
            public const string Request_TokenSecret_Session = "Request_TokenSecret";

            /// <summary>
            /// 授权Token Session键
            /// </summary>
            public const string Access_Token_Session = "Access_Token";

            /// <summary>
            /// 授权Token密钥Session键
            /// </summary>
            public const string Access_TokenSecret_Session = "Access_TokenSecret";

            /// <summary>
            /// MessageID的长度
            /// </summary>
            public const int MessageIDLength = 7;

            /// <summary>
            /// 平台应用的提供商代码
            /// </summary>
            public const string PlatformProvider = "0000000000";

            /// <summary>
            /// 平台应用的提供商名称
            /// </summary>
            public const string PlatformProviderName = "平台";

            /// <summary>
            /// 从不同系统进入后共通样式（此cookie记录从何系统进入），无值时用默认样式
            /// </summary>
            public const string Logon_Style_Cookie = "jse_logon_style";
        }

        /// <summary>
        /// 全局共通消息ID
        /// </summary>
        public struct MessageCode
        {
            /// <summary>
            /// 程序发生预期外错误
            /// </summary>
            public const string Msg_UnExpectedError = "ECO0001";

            /// <summary>
            /// 编号发生溢出
            /// </summary>
            public const string Msg_NumberOverFlow = "ECO0002";

            /// <summary>
            /// 参数错误
            /// </summary>
            public const string Msg_ParamIsWrong = "ECO0003";

            /// <summary>
            /// 参数错误,请查阅三源API文档
            /// </summary>
            public const string Msg_APIParamIsWrong = "ECO0004";

            /// <summary>
            /// 格式不支持，仅仅支持XML或JSON格式
            /// </summary>
            public const string Msg_APIUrlFormatIsWrong = "ECO0005";

            /// <summary>
            /// source参数(appkey)缺失
            /// </summary>
            public const string Msg_MissingParaKeySource = "ECO0006";
        }

        /// <summary>
        /// 配置文件名称
        /// </summary>
        public struct ConfigName
        {
            /// <summary>
            /// 环境配置文件
            /// </summary>
            public const string Environment = "Environment.config";

            /// <summary>
            /// 环境配置文件(全局设置相关)
            /// </summary>
            public const string Environment_Global = "Environment_Global.config";

            /// <summary>
            /// 环境配置文件(缓存设置相关)
            /// </summary>
            public const string Envrionment_Cache = "Environment_Cache.config";

            /// <summary>
            /// 环境配置文件(键值对参数相关)
            /// </summary>
            public const string Environment_NameValue = "Environment_NameValue.config";

            /// <summary>
            /// 环境配置文件(支付配置相关)
            /// </summary>
            public const string Environment_Pay = "Environment_Pay.config";

            /// <summary>
            /// 环境配置文件(管理中心菜单)
            /// </summary>
            public const string Environment_AdminMenu = "Environment_AdminMenu.config";

            /// <summary>
            /// 环境配置文件(短信邮件配置相关)
            /// </summary>
            public const string Environment_Communication = "Environment_Communication.config";

            /// <summary>
            /// 环境配置文件(消息文件配置相关)
            /// </summary>
            public const string Environment_Message = "Environment_Message.config";

            /// <summary>
            /// 环境配置文件(Oauth登录配置相关)
            /// </summary>
            public const string Environment_Oauth = "Environment_Oauth.config";

            /// <summary>
            /// 环境配置文件(图片文件存储配置相关)
            /// </summary>
            public const string Environment_PicStore = "Environment_PicStore.config";

            /// <summary>
            /// 环境配置文件(图片格式限制配置相关)
            /// </summary>
            public const string Environment_Picture = "Environment_Picture.config";

            /// <summary>
            /// 环境配置文件(事务配置相关)
            /// </summary>
            public const string Environment_Transaction = "Environment_Transaction.config";

            /// <summary>
            /// 环境配置文件(API宿主网站)
            /// </summary>
            public const string Environment_API = "Environment_API.config";

            /// <summary>
            /// 依赖注入配置文件
            /// </summary>
            public const string Unity = "Unity.config";

            /// <summary>
            /// 日志记录配置文件
            /// </summary>
            public const string Logger = "Logger.config";

            /// <summary>
            /// 自定义路由配置文件
            /// </summary>
            public const string RouteMap = "MapRoute.config";
        }

        /// <summary>
        /// 验证常量
        /// </summary>
        public struct ValidConstant
        {
            /// <summary>
            /// 身份证验证常量
            /// </summary>
            public static string[] IdenityNum = new string[] { 
                "11", "12", "13", "14", "15",
                "21", "22", "23",
                "31", "32", "33", "34", "35", "36", "37",
                "41", "42", "43","44","45","46",
                "50","51","52","53","54",
                "61","62","63","64","65",
                "71",
                "81","82"};

            /// <summary>
            /// 17位数对应的加权因子，自左至右
            /// </summary>
            public static int[] WI = new int[] { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };

            /// <summary>
            /// 余数对应的校验码
            /// </summary>
            public static string[] VI = new string[] { "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" };
        }

        /// <summary>
        /// 全局消息常量
        /// </summary>
        public struct GlobalConstantMessage
        {
            /// <summary>
            /// 重新加载环境配置文件成功
            /// </summary>
            public const string ReloadEnvironmentSuccess = "重新加载环境配置文件成功";

            /// <summary>
            /// 缓存清除成功
            /// </summary>
            public const string ClearCacheSuccess = "缓存清除成功";

            /// <summary>
            /// 缓存清除失败,详细请见网站错误日志
            /// </summary>
            public const string ClearCacheFail = "缓存清除失败,详细请见网站错误日志";
        }

        //public struct Constant
        //{
        //    public static bool ErrorPageEnable { get { return AppSettingHelper.GetBoolean("ErrorPageEnable", true); } }
        //}


        public static string[] EngNumbers = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };

    }
}